package com.itheima;

//已知序列1, 1, 2, 3, 5, 8, 13..., 求第12个数字是多少.
public class Demo06 {
    public static void main(String[] args) {
        //定义一个int类型的数组, 数组名叫: a, 数组的长度是12.
        int[] a = new int[12];
        //赋值
        a[0] = 1;
        a[1] = 1;
        //for循环求解
        for (int i = 2; i < 12; i++) {
            a[i] = a[i - 1] + a[i - 2];
        }

        System.out.println(a[11]);
        //方法2 使用递归求解
        System.out.println(way2(11));
    }

    //静态方法递归求解
    static int way2(int x) {
        if (x == 1 || x == 0)
            return 1;
        else
            return way2(x - 1) + way2(x - 2);

    }
}
